package com.no1.zy.config;

import org.springframework.amqp.core.*;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

@Configuration
public class RabbitMQConfig {

    @Bean
    public Queue simpleQueue(){
        return new Queue("my_simple_queue");
    }

    @Bean
    public Queue workQueue() {
        return new Queue("my_work_queue");
    }

    @Bean
    public Queue topicQueue1(){
        return new Queue("my_topic_q1");
    }

    @Bean
    public Queue topicQueue2(){
        return new Queue("my_topic_q2");
    }

    @Bean
    public TopicExchange topicExchange(){
        return new TopicExchange("my_topic_x");
    }

    @Bean
    public Binding tq1BindX(Queue topicQueue1,TopicExchange topicExchange){
        return BindingBuilder.bind(topicQueue1()).to(topicExchange()).with("fan.*.abc");

    }

    @Bean
    public Binding tq2BindX(Queue topicQueue2, TopicExchange topicExchange){
        return BindingBuilder.bind(topicQueue2()).to(topicExchange()).with("fan.#");

    }



    @Bean
    public Queue fairQueue() {
        return new Queue("my_fair_queue");
    }



    @Bean
    public Queue fanoutQueue1(){
        return new Queue("my_fanout_q1");
    }

    @Bean
    public Queue fanoutQueue2(){
        return new Queue("my_fanout_q2");
    }

    @Bean
    public FanoutExchange fanoutExchange(){
        return new FanoutExchange("my_fanout_x");
    }

    @Bean
    public Binding fa1BindX(Queue fanoutQueue1, FanoutExchange fanoutExchange){
        return BindingBuilder.bind(fanoutQueue1()).to(fanoutExchange());

    }
    @Bean
    public Binding fa2BindX(Queue fanoutQueue2, FanoutExchange fanoutExchange){
        return BindingBuilder.bind(fanoutQueue2()).to(fanoutExchange());

    }


    @Bean
    public Queue directQueue1(){
        return new Queue("my_direct_q1");
    }

    @Bean
    public Queue directQueue2(){
        return new Queue("my_direct_q2");
    }

    @Bean
    public DirectExchange directExchange(){
        return new DirectExchange("my_direct_x");
    }

    @Bean
    public Binding dir1BindX(Queue directQueue1,DirectExchange directExchange){
        return BindingBuilder.bind(directQueue1()).to(directExchange()).with("zs.abc1");

    }

    @Bean
    public Binding dir2BindX(Queue directQueue2, DirectExchange directExchange){
        return BindingBuilder.bind(directQueue2()).to(directExchange()).with("yyy.jj");

    }

}
